//
//  BTC+Account+BIP32.swift
//  XHWalletUtils
//
//  Created by xinph on 2020/5/19.
//  Copyright © 2020 xinph. All rights reserved.
//

import Foundation

extension BTC: BIP32 {
    public func UNSAFE_getPrivateAndPublicKey(password: String, address: String) -> coswift.Promise<(pub: String, pri: String)> {
        let promise = coswift.Promise<(pub: String, pri: String)>()
        
        guard let keystore = self.mnemonicKeystore else {
            print(notSuppurt)
            promise.reject(error: XHError(generatePrivateKeyFailure))
            return promise
        }
        let `private` = keystore.xpri
        let `public` = keystore.xpub
        guard !`private`.isEmpty else {
            promise.reject(error: XHError(generatePrivateKeyFailure))
            return promise
        }
        promise.fulfill(value: (pub: `public`, pri: `private`))
        return promise
    }
}
